import {timer} from '@/utils'
import {BsHouse,BsTrash} from 'react-icons/bs'



import './index.less'

function CommentItem(props) {
  const renderStatus = (val) => {
    if (val == 1) {
      return <div className='status yellow'>待审核</div>
    } else if (val == 2) {
      return <div className='status green'>审核通过</div>
    } else if (val == 3) {
      return <div className='status red'>审核拒绝</div>
    }
  }

  return (
    <div className='comment-item' onClick={() => {
      props.handleClick && props.handleClick(props?.comment?.id)
    }}>
      <div className='header'>
        <img src={props?.comment?.userUserInfoAvatar || require('@/assets/user.png')}/>
        <p className='name'>{props?.comment?.userNickName}</p>
        <p className='createdAt'>{timer(props.comment?.createdAt)}</p>
      </div>
      <p className='title'>{props?.comment?.title}</p>
      <p className='content'>{props?.comment?.content}</p>
      <div className='pictures'>
        {props?.comment?.pictures && props.comment?.pictures.split('|').map(item => (
          <img src={item} key={item}/>
        ))}
      </div>
      {props?.isMy && renderStatus(props?.comment?.status)}
      {props?.comment?.houseAddress && <p className='houseAddress'><BsHouse
        style={{marginRight: '6px', color: '#0482FF'}}/>{props?.comment?.houseAddress}</p>}
      {props?.isMy ? <div className='delete'><span onClick={(e) => {
        e.stopPropagation()
        props.handleDelete(props?.comment?.id)
      }}><BsTrash/></span></div> : ''}
    </div>
  )
}

export default CommentItem
